import java.util.*;

public class Message {

   public static final int	LOGIN 	= 0;
   public static final int	LOGOUT	= 1;
   public static final int	PUBLIC	= 2;
   public static final int	PRIVATE	= 3;

   public	int		type;
   public	String		sender;
   public	String		message;
   public	String		receiver;

   public	Message(int type, String name ) { set( type, name, "", ""); }
   public	Message(int type, String name, String msg ) { set( type, name, msg, ""); }
   public	Message(String name, String msg ) { set( PUBLIC, name, msg, ""); }
   public	Message(int type, String name, String msg, String rcvr ){
	   	   set( type, name, msg, rcvr );
   		}
   void set( int type, String sdr, String msg, String rcvr ) {
	   this.type = type; sender = sdr ; message = msg; receiver = rcvr;
   }

   public Vector<String> toVector( ) {
	StringTokenizer token =  new StringTokenizer(receiver, ";");
	Vector<String> v = new Vector<String>( 10 );
	String        name = null;
	while ( token.hasMoreTokens() ){
		name = token.nextToken().trim();
		if ( name.length() > 0 ) v.add(name);
	}
	Collections.sort(v);
        return v;
   }	
}
		       

